﻿/**
 * Zoom calculations
 * @author Sappy
 */
package info.polguere.utils {
	
	import flash.geom.Point;
	
	public class ZoomCalculation {
		
		public static function getFinalZoom(objectOrigin : Number, startSize : Number, fixed : Number, finalSize : Number) : Number {
			return objectOrigin + (fixed - objectOrigin) * (1 - finalSize / startSize);
		}
		
		public static function getFinalZoomPoint(objectOriginX : Number, objectOriginY : Number, startWidth : Number, startHeight : Number, fixedX : Number, fixedY : Number, finalWidth : Number, finalHeight : Number) : Point {
			var finalX : Number = getFinalZoom(objectOriginX, startWidth, fixedX, finalWidth);
			var finalY : Number = getFinalZoom(objectOriginY, startHeight, fixedY, finalHeight);
			return new Point(finalX, finalY);
		}
		
	}
	
}